//
//  BYAddImageModel.h
//  ZhaoQiPei
//
//  Created by 找汽配 on 16/3/5.
//  Copyright © 2016年 祥运. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, XYImageSelectType) {
    XYImageSelectTypeNone,
    XYImageSelectTypeImage,           // 图片类型
    XYImageSelectTypeSelect,          // 图片选择类型
};

@protocol XYImageSelectModelDelegate;
@protocol XYImageSelectModelAction;

@interface XYImageSelectModel : NSObject

@property (nonatomic, assign) XYImageSelectType type;
@property (nonatomic, copy) NSString * imageURL;
@property (nonatomic, strong) UIImage * image;
@property (nonatomic, strong) id submodel;
@property (nonatomic, assign, getter=isUploading) BOOL uploading; // 是否正在上传
@property (nonatomic, assign) CGFloat progress; // 上传进度
@property (nonatomic, weak) id<XYImageSelectModelDelegate> delegate; // 代理CollectionViewCell
@property (nonatomic, weak) id<XYImageSelectModelAction> action; // 代理CollectionView

+ (instancetype)model;

- (void)modelDidUpdate;
- (void)reloadImage;
- (void)uploadImage;
- (void)uploadWillStart;
- (void)uploadDidComplete;

@end

@protocol XYImageSelectModelDelegate <NSObject>

- (void)imageSelectModelWillUploadImage;
- (void)imageSelectModelDidUploadImage;
- (void)imageSelectModelUploadingImageWithProgress:(CGFloat)progress;
- (void)imageSelectModelDidUpdate;

@end

@protocol XYImageSelectModelAction <NSObject>

/** 该代理用于重新获取图片 */
- (void)imageSelectModelReloadImage:(XYImageSelectModel *)model;
/** 该代理用于启动图片上传请求 */
- (void)imageSelectModelUploadImage:(XYImageSelectModel *)model;

@end
